<!DOCTYPE html>
<html>
<meta charset="utf-8"> 
<head>
	<title data-localize="frontcheck.title">正检</title>
<link rel="stylesheet" type="text/css" href="css/common.css">
<style type="text/css">
p{
	margin: 0;
}
.u-line{
	margin: 0 auto;
	width: 770px;
    height: 600px;
    overflow: hidden;
}
.u-road{
	position: relative;
	height: 200px;
	width: 890px;
	float: right;
	margin-top: 110px;
	-webkit-transform: rotateY(180deg);
}
.u-road p{
	-webkit-transform: rotateY(180deg);
}
.u-road span{
	display: inline-block;
	-webkit-transform: rotateY(180deg);
}
.opposite{
	margin-top: 0;
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.opposite p{
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.opposite span{
	display: inline-block;
	-webkit-transform: rotateX(180deg) rotateY(180deg);
}
.u-roadcon{
	position: relative;
	float: left;
}
.u-roadcon:after{
	content: '';
	display: block;
	clear: both;
}
.u-road:after{
	content: '';
	display: block;
	clear: both;
}
.u-road-opposite:after{
	content: '';
	display: block;
	clear: both;
}
.u-track{
	position: absolute;
	height: 28px;
	width: 100%;
	left: 0;
	top: 85px;
	border-top: 1px solid #cecece;
	border-bottom: 1px solid #cecece;
}
.u-outtrack{
	position: absolute;
	height: 52px;
	width: 28px;
	left: 550px;
	top: 33px;
	border-left: 1px solid #cecece;
	border-right: 1px solid #cecece;
}
.u-aoi{
	position: absolute;
	left: 170px;
	top: -35px;
	width: 68px;
	height: 68px;
	background: #eef2f7;
	border-radius: 4px;
	border: 1px solid #29abe2;
	z-index: 10;
}
.u-aoi p{
	margin: 0;
	text-align: center;
	font-size: 16px;
	line-height: 68px;
}
.u-hand{
	position: absolute;
	width: 24px;
	height: 24px;
	top: -10px;
	left: -10px;
	border-radius: 50%; 
	background: #9acfe1;
	border: 1px solid #eee;
	z-index: -1;
}
.u-hand:after{
	content: '';
	display: block;
	width: 12px;
	height: 12px;
	margin: 0 auto;
	margin-top: 6px;
	border-radius: 6px; 
	background: #66bfdd;
}
.u-handbar{
	position: relative;
	float: left;
	width: 6px;
	height: 6px;
	margin-top: 31px;
	margin-left: 31px;
	border-radius: 4px; 
	background: #66bfdd;
	opacity: 0;
}
/*animations*/
.rotatea{
	-webkit-animation: rotatea 0.3s linear infinite;
}
@-webkit-keyframes rotatea {
0%{
	-webkit-transform: rotate(0);
}
100%{
	-webkit-transform: rotate(-90deg);
}
}
.stop {
    animation-play-state: paused;
}
.u-adjust1{
	position: absolute;
	left: 650px;
	width: 71px;
	height: 20px;
}
.u-adjust2{
	position: absolute;
	left: 410px;
	width: 71px;
	height: 20px;
}
.u-fans{
	float: left;
	margin-top: 10px;
}
.u-fans:nth-child(1){
	margin-left: 7.5px;
	margin-right: 65px;
}
.u-fans:nth-child(2){
	margin-right: 65px;
}
.fanscon{
	position: absolute;
	top: -55px;
	left: 410px;
	width: 310px;
	height: 75px;
	border: 3px solid #29abe2;
}
</style>
<link rel="stylesheet" type="text/css" href="css/machine.css">
</head>
<body>
<div class='u-head'>
   <div class="u-headcon">
	<a href="index.html"><div class="u-mainpage" data-localize="back">回到首页</div></a>
	<h3 data-localize="frontcheck.title">正检</h3>
	<div class="changeLang">
		<p class="u-lang"><span>中文</span><span>English</span></p>
	    <div isopen="true" class="changeLangBtn"></div>
	</div>
</div>
</div>
<div class="u-infos">
	<h2 data-localize="frontcheck.info_title">状态区域</h2>
	<div class="u-errorlist">
		<h3 data-localize="yichang">异常一览：</h3>
		<div class="u-errorlistcon">
		</div>
	</div>
	<p class="status"><span data-localize="frontcheck.running">运行状态：</span><span class="u-cube t-status"></span></p>
</div>
<div class="t-con">
<div class="u-line">
	<div class="u-boxcon needleft u-boxconspe" id="u-boxe"><div class="u-box u-boxe"></div></div>
	<div class="u-road lineA">
		<div class="fanscon">
			<div class="u-fans"></div>
			<div class="u-fans"></div>
			<div class="u-fans"></div>
		</div>
		<div class="u-adjust1 u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust1 u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust2 u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust2 u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-track"></div>
		<div class="u-aoi"><p data-localize="frontcheck.checkbox">AOI</p></div>
		<div class="u-boxcon stop"><div class="u-box u-box6"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box5"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box4"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box3"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box2" id="u-box2"></div><p></p></div>
		<div class="u-boxcon stop"><div class="u-box u-box1"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box1"></div></div>
	</div>
	<div class="u-road lineB">
		<div class="fanscon">
			<div class="u-fans"></div>
			<div class="u-fans"></div>
			<div class="u-fans"></div>
		</div>
		<div class="u-adjust1 u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust1 u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust2 u-adjusttop"><img src="image/adjust.png" width="100%"></div>
		<div class="u-adjust2 u-adjustbottom"><img src="image/adjust.png" width="100%"></div>
		<div class="u-track"></div>
		<div class="u-aoi"><p data-localize="frontcheck.checkbox">AOI</p></div>
		<div class="u-boxcon stop"><div class="u-box u-box6"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box5"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box4"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box3"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box2" id="u-box2-b"></div><p></p></div>
		<div class="u-boxcon stop"><div class="u-box u-box1"><p></p></div></div>
		<div class="u-boxcon stop"><div class="u-box u-box1"></div></div>
	</div>
</div>
</div>
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/language_cookie.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var lastData = null,
	si=null,
	isrotate = false;
var url = getUrl("frontcheck");
var isFirst = true;
var request = new GetRequest();
var showval= request.type; 
if ('WebSocket' in window) {
    websocket = new WebSocket(url+'/'+request.line+'/'+request.index);
}else {
    alert('Not support websocket')
}
if (request.line == "A") {
	$('.lineB').hide();
	$('.lineA').show();
}else if (request.line == "B") {
	$('.lineA').hide();
	$('.lineB').show();
}
websocket.onerror = function () {
    $('.u-boxcon,.u-adjust').addClass('stop');
    $('.u-box4').addClass('stop');
};

websocket.onopen = function (event) {
    $('.u-boxcon,.u-adjust').removeClass('stop');
    $('.u-box4').removeClass('stop');
    $('.u-box2').removeClass('break');
}
function count(obj){
    for (var i = 0; i < obj.length; i++) {
       (function(i){
       		if (obj[i].silicon_id && obj[i].silicon_id != '0') {
            $('.u-box'+obj[i].stack_index).parent().find('p').html(obj[i].silicon_id);    
            //console.log(obj[i].stack_index);
            var tmp = i+1;
            if (obj[i].silicon_status == 1) {
            	if (obj[i].stack_index == 1 ||obj[i].stack_index == 2) {
            		$('.u-box'+obj[i].stack_index).addClass('printed');
            	}else{
            		$('.u-box'+obj[i].stack_index).addClass('printed3');
            	}
            }else if(obj[i].silicon_status == 0){
                if (obj[i].stack_index == 1 ||obj[i].stack_index == 2) {
            		$('.u-box'+obj[i].stack_index).addClass('printed');
            	}else{
            		$('.u-box'+obj[i].stack_index).addClass('printed3');
            	}
            }else{
                if (obj[i].stack_index == 1 ||obj[i].stack_index == 2) {
            		$('.u-box'+obj[i].stack_index).addClass('printed');
            	}else{
            		$('.u-box'+obj[i].stack_index).addClass('printed3');
            	}
            }
        }
       })(i); 
    }
}
function reset(){
	$('.u-box').find('p').html("");
	$('.u-box').removeClass('printed');
	$('.u-box').removeClass('break');
	$('.u-box').removeClass('empty');
}
function addanimate(obj){
    for (var i = 0; i < obj.length; i++) {
       (function(i){
            if (obj[i].isPause == 0){
                if (obj[i].stack_index == 2) {
                	isrotate = true;
                }
                $('.u-box'+obj[i].stack_index).parent().addClass('moveleft');
            }else{
            	if (obj[i].stack_index == 2) {
                	isrotate = false;
                }
            }

       })(i); 
    }
}
websocket.onmessage = function (event) {
	$('#u-boxe').addClass('moveleft');
    si = JSON.parse(event.data.replace(/\bNaN\b/g, "null"));
    if (!lastData) {
    	lastData = si;
    }
    if (si.isPause1 == 0) {
    	$('.u-adjust1.u-adjusttop').addClass('u-adjustup');
    	$('.u-adjust1.u-adjustbottom').addClass('u-adjustdown');
    }else if (si.isPause1 == 1) {
    	$('.u-adjust1.u-adjusttop').removeClass('u-adjustup');
    	$('.u-adjust1.u-adjustbottom').removeClass('u-adjustdown');
    }
    if (si.isPause2 == 0) {
    	$('.u-adjust2.u-adjusttop').addClass('u-adjustup');
    	$('.u-adjust2.u-adjustbottom').addClass('u-adjustdown');
    }else if (si.isPause2 == 1) {
    	$('.u-adjust2.u-adjusttop').removeClass('u-adjustup');
    	$('.u-adjust2.u-adjustbottom').removeClass('u-adjustdown');
    }
    changeColor($('.t-status'),si.p2);
	if (isFirst) {
    	count(si.stack_list);
		isFirst = false;
    }
    errorRender();
	addanimate(si.stack_list);
    lastData = si;
    console.log(si.stack_list);
    //$('.u-boxcon').addClass('moveleft');
}

document.getElementById('u-boxe').addEventListener("webkitAnimationIteration", function(){
	reset();
	count(si.stack_list);
	if (si.stack_list.length > 1 && isrotate) {
		$('.u-box2').addClass('rotatea');
	}
	$('.u-boxcon').removeClass('moveleft');
}, false);
document.getElementById('u-box2').addEventListener("webkitAnimationIteration", function(){
	$('.u-box2').removeClass('rotatea').addClass('printed3');
}, false);
document.getElementById('u-box2-b').addEventListener("webkitAnimationIteration", function(){
	$('.u-box2').removeClass('rotatea').addClass('printed3');
}, false); 
window.onbeforeunload = function(){
	websocket.close();
}       
</script>
</body>
</html>